//
//  DisovryViewController.swift
//  xiaofenshu
//
//  Created by zhu jinlong on 2021/5/18.
//

import UIKit
import XLPagerTabStrip
class DisovryViewController: ButtonBarPagerTabStripViewController, IndicatorInfoProvider {

   
    
    override func viewDidLoad() {
        settings.style.selectedBarHeight = 0
        settings.style.buttonBarItemBackgroundColor = .clear
        settings.style.buttonBarItemFont = .systemFont(ofSize: 14.0)
        
        super.viewDidLoad()
        self.view.backgroundColor = .purple
        
        
        changeCurrentIndexProgressive = { (oldCell: ButtonBarViewCell?, newCell: ButtonBarViewCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in

            guard changeCurrentIndex == true else {return}

            oldCell?.label.textColor = .secondaryLabel
            newCell?.label.textColor = .label
            
            if animated {
                UIView.animate(withDuration: 0.1, animations: { () -> Void in
                    newCell?.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
                    oldCell?.transform = CGAffineTransform(scaleX: 0.8, y: 0.8)
                    })
                }else {
                    newCell?.transform = CGAffineTransform(scaleX: 1.0, y: 1.0)
                    oldCell?.transform = CGAffineTransform(scaleX: 0.8, y: 0.8)
                }
        }
    }
    
    override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] {
        var mutArray:Array<WaterFallVc> = []

        for name in kChannels {
            let con = storyboard!.instantiateViewController(identifier: waterfallVcId) as! WaterFallVc
            con.channel = name
            mutArray.append(con)
        }

        return mutArray
    }
    
    func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
        IndicatorInfo(title:"发现")
    }

}
